﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.CodeDom.Compiler;

using Microsoft.CSharp;

namespace WorkStation.Frameworks.Core.Reflection
{
    /// <summary>
    /// * 动态编译类的辅助类
    /// </summary>
    public class CompileHelper
    {
        public static Assembly CompileAssembly(string sourceCode, string[] assemblyNames)
        {
            CSharpCodeProvider ccp = new CSharpCodeProvider();
            CompilerParameters param = new CompilerParameters(assemblyNames);
            CompilerResults cr = ccp.CompileAssemblyFromSource(param, sourceCode);

            return cr.CompiledAssembly;
        }
    }
}
